feat(resolution): index GoFrame g.Meta routes, link to controller methods (#747)#803
feat(resolution): index GoFrame g.Meta routes, link to controller methods (#747)#803maxmilian wants to merge 1 commit into
Conversation
…hods (colbymchenry#747) GoFrame binds routes reflectively — the path/method live in a g.Meta struct tag on the request type, and the handler is the controller method named after that type with the Req suffix dropped (ChatReq -> Chat). So there was no literal route string and no call edge: route questions could only be answered lexically. Extend goResolver.extract to read the g.Meta tag (path: + method:, defaulting to ANY when method is absent) into a route node and link it to the controller method by the naming convention. Route node and its method edge are emitted together — a g.Meta whose type doesn't follow the …Req convention is skipped rather than left as an orphan route node. Only the relative path: from the tag is captured; joining the s.Group("/api", …) prefix is left to a follow-up. Follow-up to colbymchenry#720 (structural coverage, distinct from the ranking fix).
|
Code Review |
Follow-up to #720 (suggestion #3 — structural route coverage, distinct from the ranking fix). Closes #747.
Why
GoFrame binds routes reflectively, so there's no literal
/chatstring and no call edge from path → controller method:Today "where is this route registered / which method handles it" can only be answered lexically — route-registration symbols have nothing to win on.
What
Extend
goResolver.extract(src/resolution/frameworks/go.ts) with a GoFrame pass:g.Metastruct tag (path:+method:, defaulting toANYwhenmethod:is absent) → aroutenode, identical in shape to the existing Gin/mux route nodes, andReqsuffix dropped,ChatReq→Chat) via areferencesedge — same shape as the existing route→handler edges.The route node and its method edge are emitted together: a
g.Metawhose type doesn't follow the…Reqconvention (or has nopath:) is skipped rather than left as an orphan route node, per the "partial coverage is worse than none" guidance.Scope / follow-ups (intentional)
path:from the tag is captured (/chat), not thes.Group("/api", …)prefix that GoFrame prepends. The route node + method edge are still complete and useful; joining the group prefix (cross-file) is a clean follow-up.referencesedge resolves through the same name-resolution path as the existing Gin/mux route handlers. There's no GoFrame-specificresolve()pattern, so a method name resolves like any PascalCase ref; a dedicated method-kind resolution pattern is possible follow-up hardening (same risk profile as today's route-handler refs).Tests
Two unit cases added to
goResolver.extractin__tests__/frameworks.test.ts(mirroring the existing Gin/mux/Rust route-extraction tests):g.Metawithmethod:"post"→POST /chat+Chatedge; method-lessg.Meta→ANY /list+Listedge. Both assert the edge binds to the route node id.Validation
npm run build— clean (tsc).npx vitest run __tests__/frameworks.test.ts— 96 passed, no existing route tests broken.codegraph/CLAUDE.mdif you want it in the PR.